package com.hontech.bv.conn.api

import com.hontech.bv.conn.Proto
import com.hontech.bv.conn.SerialPortMod
import com.hontech.bv.conn.serial.Uint16
import com.hontech.bv.conn.serial.Uint8

object Pearl {


    suspend fun updownCtrl(type: Int) {
        SerialPortMod.request(
            Proto.REQ_PEARL_UPDOWN_CTRL,
            Proto.ID_PEARL,
            arrayOf(Uint8(type))
        ).assert("测试升降")
    }

    suspend fun dumpCtrl(type: Int) {
        SerialPortMod.request(
            Proto.REQ_PEARL_DUMP_CTRL,
            Proto.ID_PEARL,
            arrayOf(Uint8(type))
        ).assert("测试倾倒")
    }

    suspend fun moveCtrl(position: Int) {
        SerialPortMod.request(
            Proto.REQ_PEARL_MOVE_CTRL,
            Proto.ID_PEARL,
            arrayOf(Uint16(position))
        ).assert("移动倾倒")
    }

    suspend fun cargoCtrl(position: Int) {
        SerialPortMod.request(
            Proto.REQ_PEARL_CARGO_CTRL,
            Proto.ID_PEARL,
            arrayOf(Uint16(position))
        ).assert("货架测试")
    }

    suspend fun pdeCtrl(type: Int) {
        SerialPortMod.request(
            Proto.REQ_PEARL_PDE_CTRL,
            Proto.ID_PEARL,
            arrayOf(Uint8(type))
        ).assert("测试压紧电磁铁")
    }

    suspend fun init() {
        SerialPortMod.request(
            Proto.REQ_PEARL_INIT,
            Proto.ID_PEARL,
            arrayOf()
        ).assert("初始化")
    }

    suspend fun pick(col: Int, duration: Int, temp: Int) {
        SerialPortMod.request(
            Proto.REQ_PEARL_PICK,
            Proto.ID_PEARL,
            arrayOf(Uint8(col), Uint8(duration), Uint8(temp))
        ).assert("取货")
    }
}
